home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
LOGIC Apps
/
Logic-APPLE_II_APPS.iso
/
mac
/
LOGIC Apple II 5.25" Library - ProDOS
/
PRO027A.dsk
/
ADB.READER.bas
next >
Wrap
BASIC Source File
|
2012-02-16
|
6KB
|
112 lines
100 REM *** Open-Apple's ADB Reader ***
101 REM by Tom Weishaar, Feb 1987
1000 REM program initialization
1010 LOMEM: 16384 + PEEK(105) + PEEK(106) *256: REM create 16384-byte buffer
1020 CLEAR : REM restart point for reading another file
1030 DEF FN PK2(ADR) = PEEK(ADR) + PEEK(ADR +1) *256: REM 2-bye peek function
1032 DIM CN$(30): REM this array is for category names
1034 DIM C$(30): REM this array is for the information in categories
1036 DIM TB(30,2): REM this array is for category TAB positions on screen
1038 DIM MO$(12): REM this array is for the names of the months
1040 MO$(1) = "Jan":MO$(2) = "Feb":MO$(3) = "Mar"
1042 MO$(4) = "Apr":MO$(5) = "May":MO$(6) = "Jun"
1044 MO$(7) = "Jul":MO$(8) = "Aug":MO$(9) = "Sep"
1046 MO$(10) = "Oct":MO$(11) = "Nov":MO$(12) = "Dec"
1050 BBG = FN PK2(105) -16384: REM bbg points to the beginning of our buffer
1052 BEN = BBG +16384/2: REM ben points to the end of our buffer
1054 PNTR = BBG: REM pntr points to our position in the buffer
1056 BYTE = 0: REM byte points to our position in the file
1060 PRINT CHR$(4);"PR#3": PRINT : REM 80-column screen required
1062 VTAB 10
1064 PRINT "What is the name of the AppleWorks database file you want to see?"
1066 PRINT
1068 INPUT F$: HOME
1070 IF F$ = "" THEN END
1100 REM load first section of file and dig stuff out of the header
1110 GOSUB 5500: REM load file
1120 HL = FN PK2(PNTR) +2: IF HL >1017 THEN 5900: REM header length
1122 NR = FN PK2(PNTR +36): REM # of records in file
1124 NC = PEEK(PNTR +35): IF NC >30 THEN 5900: REM # of categories
1126 NF = PEEK(PNTR +38): IF NF >8 THEN 5900: REM # of report formats
1130 FOR N = 0 TO NC -1: REM get screen positions
1132 TB(N,0) = PEEK(PNTR +186 +N): REM screen sequence left-top to right-bot
1134 TB(N,1) = PEEK(PNTR +114 +N): REM horizontal screen position
1136 TB(N,2) = PEEK(PNTR +150 +N): REM vertical screen position
1138 NEXT
1140 PNTR = PNTR +357: REM get category names
1142 FOR N = 0 TO NC -1
1144 C$ = "": FOR I = 1 TO PEEK(PNTR):C$ = C$ + CHR$( PEEK(PNTR +I)): NEXT
1146 CN$(N) = C$:PNTR = PNTR +22
1148 NEXT
1150 PNTR = PNTR +NF *600: REM skip over 600-byte-each report formats
1152 IF PNTR = >BEN THEN GOSUB 5500: REM do formats extend beyond buffer?
1160 REM just for fun, draw an AppleWorks-like screen for display
1162 PRINT "File: "; RIGHT$(F$,20): PRINT : PRINT "Selection: All records"
1164 VTAB 1: POKE 1403,28: PRINT "Open-Apple's ADB.READER"
1166 VTAB 7: FOR I = 1 TO 8: PRINT "==========";: NEXT
1168 VTAB 23: FOR I = 1 TO 8: PRINT "----------";: NEXT
1170 PRINT "Press spacebar to see next record.";
1200 REM get records and display them on the screen
1210 FOR R = 0 TO NR
1220 GOSUB 5000: REM this loads c$(n) with record's data
1230 REM the rest of this just displays the data on the screen
1232 VTAB 6: POKE 1403,0
1234 IF R = 0 THEN PRINT "Standard Values for this file:": GOTO 1238
1236 PRINT "Record ";R;" of ";NR;":"; CHR$(29): REM chr$(29) clears line
1238 FOR N = 0 TO NC -1
1240 VTAB TB(N,2) +1: POKE 1403,TB(N,1) -1
1242 PRINT CN$(TB(N,0) -1);": ";C$(TB(N,0) -1); CHR$(29)
1250 NEXT
1260 VTAB 24: POKE 1403,37: GET A$: PRINT A$;: REM wait for key
1270 NEXT
1300 REM end game
1310 HOME : VTAB 12
1320 PRINT "That's all the records in ";F$
1330 PRINT
1340 PRINT "Would you like to see another? <Y/N> ";: GET A$: PRINT A$: HOME
1350 IF A$ = "Y" OR A$ = "y" THEN 1020
1360 END
5000 REM read record's categories into c$(1)...c$(n)
5010 RL = FN PK2(PNTR):PNTR = PNTR +2: REM rl is record's length
5020 IF PNTR +RL = >BEN THEN GOSUB 5500: REM does record extend beyond buffer?
5030 NB = 0: REM init # of blanks to 0
5040 FOR N = 0 TO NC -1: GOSUB 5100: NEXT : REM get category data
5050 GOSUB 5100: IF CBYTE < >255 THEN 5900: REM get $ff at end of record
5060 RETURN
5100 REM read a single category's data into c$(n)
5110 IF NB >0 THEN 5184: REM in the middle of multiple blanks?
5112 CBYTE = PEEK(PNTR):PNTR = PNTR +1: REM get control byte
5114 IF CBYTE >127 THEN 5180: REM start multiple blank categories
5116 T = PEEK(PNTR): IF T <128 THEN 5160: REM dte or time category?
5118 IF T = 212 THEN 5130
5120 REM category contains a date
5122 YR$ = CHR$( PEEK(PNTR +1)) + CHR$( PEEK(PNTR +2))
5124 MO$ = MO$( PEEK(PNTR +3) -64)
5126 DY$ = CHR$( PEEK(PNTR +4)) + CHR$( PEEK(PNTR +5))
5128 C$ = MO$ +" " +DY$ +" " +YR$: GOTO 5190
5130 REM category contains a time
5132 M$ = "AM":HR = ( PEEK(PNTR +1) -65)
5134 IF HR >11 THEN M$ = "PM": IF HR >12 THEN HR = HR -12
5136 HR$ = STR$(HR): IF HR <10 THEN HR$ = "0" +HR$
5138 MI$ = CHR$( PEEK(PNTR +2)) + CHR$( PEEK(PNTR +3))
5140 C$ = HR$ +":" +MI$ +" " +M$: GOTO 5190
5160 REM category contains ASCII-string data
5162 C$ = "": FOR I = PNTR TO PNTR +CBYTE -1:C$ = C$ + CHR$( PEEK(I)): NEXT
5164 GOTO 5190
5180 REM category is blank
5182 NB = CBYTE -128: REM cbyte-$80 is # of blank categories
5184 C$(N) = "":NB = NB -1: GOTO 5195
5190 C$(N) = C$:PNTR = PNTR +CBYTE: REM advance pointer to next category
5195 RETURN
5500 REM load section of file into buffer
5510 BYTE = BYTE +(PNTR -BBG):PNTR = BBG
5520 PRINT CHR$(4);"BLOAD";F$;",TADB,L8192,A";BBG;",B";BYTE
5530 RETURN
5900 REM the file doesn't look right--probably a program, not a file, bug
5910 HOME : VTAB 10
5920 PRINT "I've encountered an error in the file's structure"
5930 PRINT " in record ";R;" and category ";N;"."
5940 PRINT
5950 PRINT "The file buffer begins at ";BBG;" and ends at ";BEN;"."
5960 PRINT " The buffer pointer is at byte ";PNTR;"."
5990 END